const globalMethods = {
	async updateUserInfo() {
		const {
			data
		} = await this.$u.post(this.$restUrl.getUserInfo);
		this.$u.vuex('userInfo', data);
		console.log('11111111111111111111111')
	},
	getPayType() {
		return new Promise(resolve => {
			if (!this.userInfo) {
				uni.showModal({
					title: '提示',
					content: '本次操作需要您进行登录验证',
					success: (res) => {
						if (res.confirm) {
							this.$u.route('/pages_login/login_entry/loginEntry');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			} else if (this.userInfo && this.userInfo.vip > 0) {
				resolve(3);
			} else {
				uni.showActionSheet({
					itemList: ['余额支付', '微信支付'],
					success: async (res) => {
						if (res.tapIndex == 0) {
							resolve(1);
						} else {
							resolve(2);
						}
					},
				});
			}
		})
	}
}

module.exports = {
	methods: {
		...globalMethods
	}
}
